package com.yijinsuo.activity;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.yijinsuo.R;
import com.yijinsuo.base.BaseActivity;
import com.yijinsuo.base.BaseFragment;
import com.yijinsuo.entity.Page;
import com.yijinsuo.fragment.RenChouCommonProblemsFragment;
import com.yijinsuo.fragment.RenChouListFragment;
import com.yijinsuo.fragment.RenChouProjectIntroductionFragment;
import com.yijinsuo.view.TitleBar;
import com.yijinsuo.view.XViewPagerIndicator;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 项目介绍", "认筹列表","常见问题
 */
public class RenChouXiangmuDetailsActivity extends BaseActivity {

    @Bind(R.id.titlebar)
    TitleBar titlebar;
    @Bind(R.id.id_stickynavlayout_indicator)
    XViewPagerIndicator mViewPagerindicator;
    @Bind(R.id.id_stickynavlayout_viewpager)
    ViewPager mviewPager;

    private String[] titles = { "项目介绍", "认筹列表","常见问题"};
    private List<BaseFragment> fragments = new ArrayList<BaseFragment>();
    //
    private Page info;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_ren_chou_xiangmu_details);
        ButterKnife.bind(this);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initTitle() {
        info = (Page) getIntent().getSerializableExtra("info");
        titlebar.setTitleBar(R.drawable.back_selector, info.getBorrowTitle(), 0);

    }

    @Override
    protected void initView() {

        fragments.add(new RenChouProjectIntroductionFragment());
        fragments.add(new RenChouListFragment());
        fragments.add(new RenChouCommonProblemsFragment());
        mViewPagerindicator.setIndicatorColor(Color.BLUE);
        mviewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager()));
        mViewPagerindicator.setTitles(titles, mviewPager);
        mViewPagerindicator.setIndicatorColor(Color.RED);

    }

    @Override
    protected void setData() {

    }

    @Override
    protected void widgetClick(View view) {

    }


    class ViewPagerAdapter extends FragmentPagerAdapter {

        public ViewPagerAdapter(FragmentManager fm) {
            super(fm);
            // TODO Auto-generated constructor stub

        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return fragments.size();
        }

        @Override
        public Fragment getItem(int arg0) {
            // TODO Auto-generated method stub
            return fragments.get(arg0);
        }

    }

    @OnClick({R.id.titlebar_iv_back})
    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.titlebar_iv_back:

                finish();
                break;

            default:
        }

    }
}
